<template>
  <view class="balance">
    <view class="content">
      <view class="balance__top">
        <view class="balance__card">
          <u-cell-item
            :title="accountData.bankName"
            :arrow="false"
            :border-bottom="false"
          >
            <u-image
              :src="thumb"
              width="40"
              height="40"
              slot="icon"
              class="mr-10"
            ></u-image>
          </u-cell-item>
          <view class="balance__account" v-if="accountData.accountNo">
            {{ '**** **** **** ' + accountData.accountNo.substring(accountData.accountNo.length - 4) }}
          </view>
        </view>
      </view>

      <u-cell-group class="mt-20">
        <u-cell-item
          title="姓名"
          :value="accountData.accountName"
          :arrow="false"
          bg-color="#fffffF"
        ></u-cell-item>
        <view class="" v-if="accountData.accountIdCard">
          <u-cell-item
            title="身份证号"
            bg-color="#fffffF"
            :value="
              accountData.accountIdCard.substring(0, 1) +
              '****************' +
              accountData.accountIdCard.substring(
                accountData.accountIdCard.length - 1
              )
            "
            :arrow="false"
          ></u-cell-item>
        </view>
      </u-cell-group>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      accountData: {},
      thumb: '/static/image/home/icon_bank_header.png',
    };
  },
  onNavigationBarButtonTap(event) {
    uni.navigateTo({
      url: '/pages/mine/settlement/settlementUpdate',
      events: {
        // 为指定事件添加一个监听器，获取被打开页面传送到当前页面的数据
        acceptDataFromOpenedPage: (data) => {
          console.log('acceptDataFromOpenedPage----->68', data);
          if (data.data == '1') {
            this.querySetter();
          }
        },
      },
      success: (res) => {
        // 通过eventChannel向被打开页面传送数据
        res.eventChannel.emit('acceptDataFromOpenerPage', {
          data: 'data from starter page',
        });
      },
    });
  },
  mounted() {
    this.querySetter();
  },
  methods: {
    querySetter() {
      const _that = this;
      this.$zx.user_api.querySetter().then((data) => {
        console.log('querySetter----->89', data);
        this.accountData = data;
      });
    },
  },
};
</script>

<style scoped lang="scss">
.balance {
  &__top {
    background-color: white;
    padding: 20rpx;
  }

  &__card {
    background-image: url('/static/image/home/img_settlement_info_bg.png');
    height: 336rpx;
    background-position: 50% 50%;
    background-repeat: no-repeat;
    background-size: 100%;
    // margin: 30rpx 30rpx;
    border-radius: 20rpx;
    border: 1rpx solid #f6f6f6;
  }

  &__account {
    display: flex;
    justify-content: center;
    margin-top: 80rpx;
    font-size: 22px;
    font-weight: bold;
  }
}
</style>
